test(invariants): add TIP-1016 state gas invariant tests and update GasPricing/BlockGasLimits for gas dimension split#3369
Open
test(invariants): add TIP-1016 state gas invariant tests and update GasPricing/BlockGasLimits for gas dimension split#3369
Conversation
13cb3cb to
ad57193
Compare
ad57193 to
b3b1583
Compare
b3b1583 to
e43a08b
Compare
e43a08b to
1362a4d
Compare
6b8da60 to
630ee48
Compare
6b913a8 to
6e44bac
Compare
a26c48c to
0ebd6ce
Compare
cea400d to
cb20d9d
Compare
…asPricing/BlockGasLimits for gas dimension split
The invariant-tests workflow injects wrapper functions before the last closing brace in each file. With helpers at the bottom, the wrappers ended up inside the helper contract instead of the test contract. Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
The invariant-tests workflow injects wrapper functions before every '^}$' line in the test file. With helpers inline, the wrappers got injected into helper contracts too. Moved GasTestStorage, TIP1016Storage, and GasLeftChecker to test/helpers/. Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
Under TIP-1016, state gas is exempt from tx/block limits and comes from the reservoir. Operations like SSTORE only cost 20k regular gas (vs 250k total), so the old 'insufficient gas' thresholds (100k, 200k) are now sufficient. Use gas below intrinsic tx cost to guarantee failure. For RES1, use tx.gas = MAX_TX_GAS_LIMIT (not above) since the reservoir model isn't fully active in foundry's EVM runtime. Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
cb20d9d to
128a80b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates existing invariant tests and adds new ones for TIP-1016's gas dimension split (regular vs state gas).
GasPricing.t.sol: Fixedhandler_multipleNewSlotswhich was broken post-TIP-1016 — only 20k regular gas per SSTORE counts against limits, so the old "gas for 1 slot" threshold no longer caused N>1 to fail. Added state gas tracking ghost variables.BlockGasLimits.t.sol: Reworked tx gas cap enforcement —tx.gas > capis now valid when excess is state gas. Updated deployment gas calculation to split regular/state components sotx.gascan exceed the cap for large contracts.TIP1016.t.sol: New test covering 12 invariants across gas dimension split (GAS1-3), reservoir model (RES1-3), block accounting (BLK1-3), and refund semantics (REF1-2).